package com.xframe.common.core.service.login;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

//@Service
public class TokenServiceFactory {

    private static String tokenService;


    private static Map<String,ITokenService> tokenServiceMap = new HashMap<>();

    static {
        tokenService = "def";
        tokenServiceMap.put("def",new UserTokenService());
    }

    @Value("${login.TokenService}")
    public void setTokenService(String tokenService) {
        TokenServiceFactory.tokenService = tokenService;
        if(!tokenServiceMap.containsKey(tokenService)){
            TokenServiceFactory.tokenService = "def";
        }

    }

    public static ITokenService create(){

        return tokenServiceMap.get(tokenService);
    }
}

